package com.bbu.javaexam.controller;

import com.bbu.javaexam.domain.MultiQuestion;
import com.bbu.javaexam.domain.RespData;
import com.bbu.javaexam.service.impl.MultiQuestionServiceImpl;
import com.bbu.javaexam.util.RespDataHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Alex
 * @version 1.0.0
 * @ClassName MultiQuestionController.java
 * @Description TODO
 */
@RestController
public class MultiQuestionController {
    @Autowired
    private MultiQuestionServiceImpl multiQuestionService;

    @GetMapping("/multiQuestionId")
    public RespData findOnlyQuestion() {
        MultiQuestion res = multiQuestionService.findOnlyQuestionId();
        return RespDataHandler.buildRespData(200, "查询成功", res);
    }

    @PostMapping("/MultiQuestion")
    public RespData add(@RequestBody MultiQuestion multiQuestion) {
        int res = multiQuestionService.add(multiQuestion);
        if (res != 0) {
            return RespDataHandler.buildRespData(200, "添加成功", res);
        }
        return RespDataHandler.buildRespData(400, "添加失败", res);
    }
}
